package com.toy.config;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateConverter implements Converter<String,Date> {

    private static  final Log log = LogFactory.getLog(DateConverter.class);
    @Override
    public Date convert(String s) {
        Date rusult = null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            rusult = sdf.parse(s);
        } catch (ParseException e) {
           log.error(e.getMessage(),e);
        }
        return rusult;
    }
}
